package com.wewins.fota.bean.bo;

import com.alibaba.fastjson.JSON;
import com.wewins.fota.bean.po.UpdatePlan;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

import java.util.Map;

@Data
@Builder
@AllArgsConstructor
public class Plan4Redis {
    private int id;

    private String name;

    private String imei;

    private String product;

    private String srcV;

    private String dstV;

    private long createTime;

    private long updateTime;

    private String description;


    public Plan4Redis fillBy(UpdatePlan plan) {
        this.id = plan.getId();
        this.name = plan.getName();
        Map map = JSON.parseObject(plan.getCond(), Map.class);
        this.imei = (String) map.get("imei");
        this.product = plan.getProduct();
        this.srcV = plan.getSrcV();
        this.dstV = plan.getDstV();
        this.createTime = plan.getCreateTime();
        this.updateTime = plan.getUpdateTime();
        this.description = plan.getDescription();
        return this;
    }
}
